package com.huawei.secure.android.common.intent;

import android.annotation.TargetApi;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcelable;
import android.util.Log;
import android.util.Size;
import android.util.SizeF;
import android.util.SparseArray;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Set;

public class SafeBundle {
    private static final String TAG = "SafeBundle";
    private final Bundle g;

    public SafeBundle() {
        this(new Bundle());
    }

    public SafeBundle(Bundle bundle) {
        if (bundle == null) {
            bundle = new Bundle();
        }
        this.g = bundle;
    }

    public Bundle getBundle() {
        return this.g;
    }

    public boolean getBoolean(String str) {
        return getBoolean(str, false);
    }

    public boolean getBoolean(String str, boolean z) {
        try {
            z = this.g.getBoolean(str, z);
        } catch (Exception e) {
            Log.e(TAG, "getBoolean exception : " + e.getMessage());
        }
        return z;
    }

    public boolean[] getBooleanArray(String str) {
        try {
            return this.g.getBooleanArray(str);
        } catch (Exception e) {
            Log.e(TAG, "getBooleanArray exception: " + e.getMessage());
            return new boolean[0];
        }
    }

    public byte getByte(String str) {
        return getByte(str, (byte) 0);
    }

    public byte getByte(String str, byte b) {
        try {
            b = this.g.getByte(str, b).byteValue();
        } catch (Exception e) {
            Log.e(TAG, "getByte exception: " + e.getMessage());
        }
        return b;
    }

    public byte[] getByteArray(String str) {
        try {
            return this.g.getByteArray(str);
        } catch (Exception e) {
            Log.e(TAG, "getByteArray exception: " + e.getMessage());
            return new byte[0];
        }
    }

    public char getChar(String str) {
        return getChar(str, '\u0000');
    }

    public char getChar(String str, char c) {
        try {
            c = this.g.getChar(str, c);
        } catch (Exception e) {
            Log.e(TAG, "getChar exception: " + e.getMessage());
        }
        return c;
    }

    public char[] getCharArray(String str) {
        try {
            return this.g.getCharArray(str);
        } catch (Exception e) {
            Log.e(TAG, "getCharArray exception: " + e.getMessage());
            return new char[0];
        }
    }

    public short getShort(String str) {
        return getShort(str, (short) 0);
    }

    public short getShort(String str, short s) {
        try {
            s = this.g.getShort(str, s);
        } catch (Exception e) {
            Log.e(TAG, "getShort exception: " + e.getMessage());
        }
        return s;
    }

    public short[] getShortArray(String str) {
        try {
            return this.g.getShortArray(str);
        } catch (Exception e) {
            Log.e(TAG, "getShortArray exception: " + e.getMessage());
            return new short[0];
        }
    }

    @RequiresApi(21)
    public CharSequence getCharSequence(String str) {
        return getCharSequence(str, null);
    }

    @RequiresApi(21)
    public CharSequence getCharSequence(String str, CharSequence charSequence) {
        try {
            charSequence = this.g.getCharSequence(str, charSequence);
        } catch (Exception e) {
            Log.e(TAG, "getCharSequence exception: " + e.getMessage());
        }
        return charSequence;
    }

    public CharSequence[] getCharSequenceArray(String str) {
        try {
            return this.g.getCharSequenceArray(str);
        } catch (Exception e) {
            Log.e(TAG, "getCharSequenceArray exception: " + e.getMessage());
            return new CharSequence[0];
        }
    }

    public ArrayList<CharSequence> getCharSequenceArrayList(String str) {
        try {
            return this.g.getCharSequenceArrayList(str);
        } catch (Exception e) {
            Log.e(TAG, "getCharSequenceArrayList exception: " + e.getMessage());
            return null;
        }
    }

    public int getInt(String str) {
        return getInt(str, 0);
    }

    public int getInt(String str, int i) {
        try {
            i = this.g.getInt(str, i);
        } catch (Exception e) {
            Log.e(TAG, "getInt exception: " + e.getMessage());
        }
        return i;
    }

    public int[] getIntArray(String str) {
        try {
            return this.g.getIntArray(str);
        } catch (Exception e) {
            Log.e(TAG, "getIntArray exception: " + e.getMessage());
            return new int[0];
        }
    }

    public ArrayList<Integer> getIntegerArrayList(String str) {
        try {
            return this.g.getIntegerArrayList(str);
        } catch (Exception e) {
            Log.e(TAG, "getIntegerArrayList exception: " + e.getMessage());
            return null;
        }
    }

    public float getFloat(String str) {
        return getFloat(str, 0.0f);
    }

    public float getFloat(String str, float f) {
        try {
            f = this.g.getFloat(str, f);
        } catch (Exception e) {
            Log.e(TAG, "getFloat exception: " + e.getMessage());
        }
        return f;
    }

    public float[] getFloatArray(String str) {
        try {
            return this.g.getFloatArray(str);
        } catch (Exception e) {
            Log.e(TAG, "getFloatArray exception: " + e.getMessage());
            return new float[0];
        }
    }

    public long getLong(String str) {
        return getLong(str, 0);
    }

    public long getLong(String str, long j) {
        try {
            j = this.g.getLong(str, j);
        } catch (Exception e) {
            Log.e(TAG, "getLong exception: " + e.getMessage());
        }
        return j;
    }

    public long[] getLongArray(String str) {
        try {
            return this.g.getLongArray(str);
        } catch (Exception e) {
            Log.e(TAG, "getLongArray exception: " + e.getMessage());
            return new long[0];
        }
    }

    public double getDouble(String str) {
        return getDouble(str, 0.0d);
    }

    public double getDouble(String str, double d) {
        try {
            d = this.g.getDouble(str, d);
        } catch (Exception e) {
            Log.e(TAG, "getDouble exception: " + e.getMessage());
        }
        return d;
    }

    public double[] getDoubleArray(String str) {
        try {
            return this.g.getDoubleArray(str);
        } catch (Exception e) {
            Log.e(TAG, "getDoubleArray exception: " + e.getMessage());
            return new double[0];
        }
    }

    @RequiresApi(api = 12)
    public String getString(String str) {
        return getString(str, null);
    }

    @RequiresApi(api = 12)
    public String getString(String str, String str2) {
        try {
            str2 = this.g.getString(str, str2);
        } catch (Exception e) {
            Log.e(TAG, "getString exception: " + e.getMessage());
        }
        return str2;
    }

    public String[] getStringArray(String str) {
        try {
            return this.g.getStringArray(str);
        } catch (Exception e) {
            Log.e(TAG, "getStringArray exception: " + e.getMessage());
            return new String[0];
        }
    }

    public ArrayList<String> getStringArrayList(String str) {
        try {
            return this.g.getStringArrayList(str);
        } catch (Exception e) {
            Log.e(TAG, "getStringArrayList exception: " + e.getMessage());
            return null;
        }
    }

    public Size getSize(String str) {
        Size size = null;
        try {
            if (VERSION.SDK_INT >= 21) {
                size = this.g.getSize(str);
            }
        } catch (Exception e) {
            Log.e(TAG, "getSize exception: " + e.getMessage());
        }
        return size;
    }

    public SizeF getSizeF(String str) {
        SizeF sizeF = null;
        try {
            if (VERSION.SDK_INT >= 21) {
                sizeF = this.g.getSizeF(str);
            }
        } catch (Exception e) {
            Log.e(TAG, "getSizeF exception: " + e.getMessage());
        }
        return sizeF;
    }

    public <T extends Parcelable> T getParcelable(String str) {
        try {
            return this.g.getParcelable(str);
        } catch (Exception e) {
            Log.e(TAG, "getParcelable exception: " + e.getMessage());
            return null;
        }
    }

    public Parcelable[] getParcelableArray(String str) {
        try {
            return this.g.getParcelableArray(str);
        } catch (Exception e) {
            Log.e(TAG, "getParcelableArray exception: " + e.getMessage());
            return new Parcelable[0];
        }
    }

    public <T extends Parcelable> ArrayList<T> getParcelableArrayList(String str) {
        try {
            return this.g.getParcelableArrayList(str);
        } catch (Exception e) {
            Log.e(TAG, "getParcelableArrayList exception: " + e.getMessage());
            return null;
        }
    }

    public <T extends Parcelable> SparseArray<T> getSparseParcelableArray(String str) {
        try {
            return this.g.getSparseParcelableArray(str);
        } catch (Exception e) {
            Log.e(TAG, "getSparseParcelableArray exception: " + e.getMessage());
            return null;
        }
    }

    public Serializable getSerializable(String str) {
        try {
            return this.g.getSerializable(str);
        } catch (Exception e) {
            Log.e(TAG, "getSerializable exception: " + e.getMessage());
            return null;
        }
    }

    public IBinder getBinder(@Nullable String str) {
        try {
            return this.g.getBinder(str);
        } catch (Exception e) {
            Log.e(TAG, "getBinder exception: " + e.getMessage());
            return null;
        }
    }

    public Bundle getBundle(@Nullable String str) {
        try {
            return this.g.getBundle(str);
        } catch (Exception e) {
            Log.e(TAG, "getBundle exception: " + e.getMessage());
            return null;
        }
    }

    public Object get(String str) {
        try {
            return this.g.get(str);
        } catch (Exception e) {
            Log.e(TAG, "get exception: " + e.getMessage());
            return null;
        }
    }

    public SafeBundle putBoolean(@Nullable String str, boolean z) {
        try {
            this.g.putBoolean(str, z);
        } catch (Exception e) {
            Log.e(TAG, "putBoolean exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putInt(@Nullable String str, int i) {
        try {
            this.g.putInt(str, i);
        } catch (Exception e) {
            Log.e(TAG, "putInt exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putLong(@Nullable String str, long j) {
        try {
            this.g.putLong(str, j);
        } catch (Exception e) {
            Log.e(TAG, "putLong exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putDouble(@Nullable String str, double d) {
        try {
            this.g.putDouble(str, d);
        } catch (Exception e) {
            Log.e(TAG, "putLong exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putString(@Nullable String str, @Nullable String str2) {
        try {
            this.g.putString(str, str2);
        } catch (Exception e) {
            Log.e(TAG, "putLong exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putBooleanArray(@Nullable String str, @Nullable boolean[] zArr) {
        try {
            this.g.putBooleanArray(str, zArr);
        } catch (Exception e) {
            Log.e(TAG, "putBooleanArray exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putIntArray(@Nullable String str, @Nullable int[] iArr) {
        try {
            this.g.putIntArray(str, iArr);
        } catch (Exception e) {
            Log.e(TAG, "putIntArray exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putLongArray(@Nullable String str, @Nullable long[] jArr) {
        try {
            this.g.putLongArray(str, jArr);
        } catch (Exception e) {
            Log.e(TAG, "putLongArray exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putDoubleArray(@Nullable String str, @Nullable double[] dArr) {
        try {
            this.g.putDoubleArray(str, dArr);
        } catch (Exception e) {
            Log.e(TAG, "putDoubleArray exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putStringArray(@Nullable String str, @Nullable String[] strArr) {
        try {
            this.g.putStringArray(str, strArr);
        } catch (Exception e) {
            Log.e(TAG, "putStringArray exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putAll(Bundle bundle) {
        if (bundle != null) {
            try {
                this.g.putAll(bundle);
            } catch (Exception e) {
                Log.e(TAG, "putAll exception");
            }
        }
        return this;
    }

    public SafeBundle putByte(@Nullable String str, byte b) {
        try {
            this.g.putByte(str, b);
        } catch (Exception e) {
            Log.e(TAG, "putByte exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putChar(@Nullable String str, char c) {
        try {
            this.g.putChar(str, c);
        } catch (Exception e) {
            Log.e(TAG, "putChar exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putShort(@Nullable String str, short s) {
        try {
            this.g.putShort(str, s);
        } catch (Exception e) {
            Log.e(TAG, "putShort exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putFloat(@Nullable String str, float f) {
        try {
            this.g.putFloat(str, f);
        } catch (Exception e) {
            Log.e(TAG, "putFloat exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putCharSequence(@Nullable String str, @Nullable CharSequence charSequence) {
        try {
            this.g.putCharSequence(str, charSequence);
        } catch (Exception e) {
            Log.e(TAG, "putCharSequence exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putParcelable(@Nullable String str, @Nullable Parcelable parcelable) {
        try {
            this.g.putParcelable(str, parcelable);
        } catch (Exception e) {
            Log.e(TAG, "putParcelable exception: " + e.getMessage());
        }
        return this;
    }

    @TargetApi(21)
    public SafeBundle putSize(@Nullable String str, @Nullable Size size) {
        try {
            this.g.putSize(str, size);
        } catch (Exception e) {
            Log.e(TAG, "putSize exception: " + e.getMessage());
        }
        return this;
    }

    @TargetApi(21)
    public SafeBundle putSizeF(@Nullable String str, @Nullable SizeF sizeF) {
        try {
            this.g.putSizeF(str, sizeF);
        } catch (Exception e) {
            Log.e(TAG, "putSizeF exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putParcelableArray(@Nullable String str, @Nullable Parcelable[] parcelableArr) {
        try {
            this.g.putParcelableArray(str, parcelableArr);
        } catch (Exception e) {
            Log.e(TAG, "putParcelableArray exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putParcelableArrayList(@Nullable String str, @Nullable ArrayList<? extends Parcelable> arrayList) {
        try {
            this.g.putParcelableArrayList(str, arrayList);
        } catch (Exception e) {
            Log.e(TAG, "putParcelableArrayList exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putSparseParcelableArray(@Nullable String str, @Nullable SparseArray<? extends Parcelable> sparseArray) {
        try {
            this.g.putSparseParcelableArray(str, sparseArray);
        } catch (Exception e) {
            Log.e(TAG, "putSparseParcelableArray exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putIntegerArrayList(@Nullable String str, @Nullable ArrayList<Integer> arrayList) {
        try {
            this.g.putIntegerArrayList(str, arrayList);
        } catch (Exception e) {
            Log.e(TAG, "putIntegerArrayList exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putStringArrayList(@Nullable String str, @Nullable ArrayList<String> arrayList) {
        try {
            this.g.putStringArrayList(str, arrayList);
        } catch (Exception e) {
            Log.e(TAG, "putStringArrayList exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putCharSequenceArrayList(@Nullable String str, @Nullable ArrayList<CharSequence> arrayList) {
        try {
            this.g.putCharSequenceArrayList(str, arrayList);
        } catch (Exception e) {
            Log.e(TAG, "putCharSequenceArrayList exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putSerializable(@Nullable String str, @Nullable Serializable serializable) {
        try {
            this.g.putSerializable(str, serializable);
        } catch (Exception e) {
            Log.e(TAG, "putSerializable exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putByteArray(@Nullable String str, @Nullable byte[] bArr) {
        try {
            this.g.putByteArray(str, bArr);
        } catch (Exception e) {
            Log.e(TAG, "putByteArray exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putShortArray(@Nullable String str, @Nullable short[] sArr) {
        try {
            this.g.putShortArray(str, sArr);
        } catch (Exception e) {
            Log.e(TAG, "putShortArray exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putCharArray(@Nullable String str, @Nullable char[] cArr) {
        try {
            this.g.putCharArray(str, cArr);
        } catch (Exception e) {
            Log.e(TAG, "putCharArray exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putFloatArray(@Nullable String str, @Nullable float[] fArr) {
        try {
            this.g.putFloatArray(str, fArr);
        } catch (Exception e) {
            Log.e(TAG, "putFloatArray exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putCharSequenceArray(@Nullable String str, @Nullable CharSequence[] charSequenceArr) {
        try {
            this.g.putCharSequenceArray(str, charSequenceArr);
        } catch (Exception e) {
            Log.e(TAG, "putCharSequenceArray exception: " + e.getMessage());
        }
        return this;
    }

    public SafeBundle putBundle(@Nullable String str, @Nullable Bundle bundle) {
        try {
            this.g.putBundle(str, bundle);
        } catch (Exception e) {
            Log.e(TAG, "putBundle exception: " + e.getMessage());
        }
        return this;
    }

    @RequiresApi(api = 18)
    public SafeBundle putBinder(@Nullable String str, @Nullable IBinder iBinder) {
        try {
            this.g.putBinder(str, iBinder);
        } catch (Exception e) {
            Log.e(TAG, "putBundle exception: " + e.getMessage());
        }
        return this;
    }

    public int size() {
        try {
            return this.g.size();
        } catch (Exception e) {
            Log.e(TAG, "size exception");
            return 0;
        }
    }

    public boolean isEmpty() {
        try {
            return this.g.isEmpty();
        } catch (Exception e) {
            Log.e(TAG, "isEmpty exception");
            return true;
        }
    }

    public void clear() {
        try {
            this.g.clear();
        } catch (Exception e) {
            Log.e(TAG, "clear exception.");
        }
    }

    public boolean containsKey(String str) {
        try {
            return this.g.containsKey(str);
        } catch (Exception e) {
            Log.e(TAG, "containsKey exception. key:");
            return false;
        }
    }

    public void remove(String str) {
        try {
            this.g.remove(str);
        } catch (Exception e) {
            Log.e(TAG, "remove exception. key:");
        }
    }

    public Set<String> keySet() {
        try {
            return this.g.keySet();
        } catch (Exception e) {
            Log.e(TAG, "keySet exception.");
            return null;
        }
    }
}
